package cn.wolfcode.crm.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.SystemDictionary;
import cn.wolfcode.crm.mapper.SystemDictionaryMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemDictionaryService;

@Service
public class SystemdictionaryServiceImpl implements ISystemDictionaryService {

	@Autowired
	private SystemDictionaryMapper systemdictionaryMapper;

	@Override
	public void saveOrUpdate(SystemDictionary entity) {
		if (entity.getId() == null) {
			systemdictionaryMapper.insert(entity);
		} else {
			systemdictionaryMapper.update(entity);
		}

	}

	@Override
	public SystemDictionary get(Long id) {
		return systemdictionaryMapper.selectById(id);
	}

	@Override
	public PageInfo<SystemDictionary> list(QueryObject qo) {
		PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
		List<SystemDictionary> list = systemdictionaryMapper.selectAll(qo);
		return new PageInfo<>(list);
	}

	@Override
	public void delete(Long id) {
		systemdictionaryMapper.delete(id);
	}

	@Override
	public List<SystemDictionary> selectAllNotPage() {
		return systemdictionaryMapper.selectAllNotPage();
	}

}
